﻿using System;

using SBPweb.PROvibe.Business.Shared.Contracts.Content;

namespace SBPweb.PROvibe.Business.Client.Library.Services.LayoutConnector
{

    public partial class LayoutProviderClient
    {

        public void GetLayoutRootItemSync(string url)
        {
            ContentItemDescriptor cid = GetLayoutRootItem(url);
            this.GetLayoutRootItemCompleted(this, new GetLayoutRootItemCompletedEventArgs(new object[] { cid }, null, false, null));
        }

        private ContentItemDescriptor GetLayoutRootItem(string url)
        {
            Uri uri = new Uri(url);
            TypeDescriptor tD = new TypeDescriptor("http://" + uri.DnsSafeHost + ":" + uri.Port + "/ClientBin/SBPweb.PROvibe.Modules.Client.Navigator.xap",
                                                    "SBPweb.PROvibe.Modules.Client.Navigator.dll",
                                                    "SBPweb.PROvibe.Modules.Client.Navigator.Pages.Main");
            ContainerDescriptor cD = new ContainerDescriptor(ContainerIdConstants.RootVisual);
            ContentItemDescriptor cI = new ContentItemDescriptor(tD, cD);

            TypeDescriptor tD0 = new TypeDescriptor("http://" + uri.DnsSafeHost + ":" + uri.Port + "/ClientBin/SBPweb.PROvibe.Modules.Client.Communication.Xmpp.xap",
                                                    "SBPweb.PROvibe.Modules.Client.Communication.Xmpp.dll",
                                                    "SBPweb.PROvibe.Modules.Client.Communication.Xmpp.Controls.MessengerMainPanel");
            ContainerDescriptor cD0 = new ContainerDescriptor(ContainerIdConstants.OverlayPanel);
            ContentItemDescriptor cI0 = new ContentItemDescriptor(tD0, cD0);

            cI.Children.Add(cI0);

            return cI;
        }

        public void GetLayoutThemeSync(string url)
        {
            TypeDescriptor td = GetLayoutTheme(url);
            this.GetLayoutThemeCompleted(this, new GetLayoutThemeCompletedEventArgs(new object[] { td }, null, false, null));
        }

        private TypeDescriptor GetLayoutTheme(string url)
        {
            Uri uri = new Uri(url);
            string themeName = "PROvibe";
            TypeDescriptor tD = new TypeDescriptor("http://" + uri.DnsSafeHost + ":" + uri.Port + "/ClientBin/SBPweb.PROvibe.Modules.Client.Themes." + themeName + ".xap",
                                                    "SBPweb.PROvibe.Modules.Client.Themes." + themeName + ".dll",
                                                    "SBPweb.PROvibe.Modules.Client.Themes." + themeName + ".Styles");

            return tD;
        }


    }

}